import random
dic = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5, "F": 6}
print("交换前：", dic)
giftsout = {}   # 存放交换后的结果
gifts = [i for i in dic.values()]   # 未分配出的礼物

for x in dic.keys():
    flag = 0
    mygift = dic.get(x)
    if mygift in gifts: # 判断自己的礼物是否在未分配礼物列表中
        flag = 1
        gifts.remove(mygift)
    getgift = random.choice(gifts)  # 随机分配礼物
    giftsout[x] = getgift
    gifts.remove(getgift)
    if flag:
        gifts.append(mygift)
print("交换后：", giftsout)


old_list = ["a", "b", "c", "d", "e", "f", "g", "h"]
leave = input("请假人员：").split()
print(f"请假人员：{leave}")
new_set = set(old_list) - set(leave)
new_list = list(new_set)
while True:
    if len(new_list) == 0:
        print("全部抽完啦")
        break
    num = random.randint(0, len(new_list)-1)
    a = input("输入q退出，其他继续：")
    if a == "q":
        print("退出")
        break
    else:
        print(f"请 {new_list[num]} 回答问题")
        new_list.pop(num)
        print()